package com.dyh.quickdemozwei.go;



import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TestGameObject {

    interface Component{

    }

    class Transform implements Component{

    }

    class Script implements Component{

    }

    class GameObject{
        Map<Class, List<Component>> mClsComponet = new HashMap<>();

        void addComponent(Component component){
            mClsComponet.computeIfAbsent(component.getClass(), k -> new ArrayList<>());
            mClsComponet.get(component.getClass()).add(component);
        }
    }

    @Test
    public void test(){
        GameObject go = new GameObject();
        Script s1 = new Script();
        Script s2 = new Script();
        Transform transform = new Transform();

        go.addComponent(s1);
        go.addComponent(s2);
        go.addComponent(transform);

        System.out.println();
    }

}
